{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                      enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">

                        <div class="form-group">
                            <label for="group_name" class="col-sm-2 control-label">分组名称</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="group_name" name="group_name" value="{$data.group_name|default=''}"
                                       placeholder="请输入分组名称" type="text" readonly class="form-control field-text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="config_hezhou" class="col-sm-2 control-label">参数配置_合宙</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea name="config_hezhou" class="form-control field-text" id="config_hezhou"
                                          cols="30" rows="10" placeholder='这里可以是任何信息、HTTP请求后都会返回'>{$data.config_hezhou|default=''}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-10 col-md-4">
                                <div class="col-md-10">
                                    <input value=""
                                           placeholder="可以在这里输入已在合宙配置好的IMEI" id="ota_name" type="text" class="form-control field-text">
                                </div>
                                <div class="col-md-2">
                                    <button type="button" class="btn flat btn-info" onclick="getOtaName();">一键获取</button>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-10 col-md-4">
                                <div class="alert alert-danger" role="alert">
                                    *API请求地址：{:request()->domain()}/api/dtu/设备号<br/>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="config_custom" class="col-sm-2 control-label">参数配置_自定义</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea name="config_custom" class="form-control field-text" id="config_custom"
                                          cols="30" rows="10" placeholder="这里可以是任何信息、HTTP请求后都会返回、与上面的请求链接不同~">{$data.config_custom|default=''}</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-10 col-md-4">
                                <div class="alert alert-danger" role="alert">
                                    *API请求地址：{:request()->domain()}/api/custom/设备号<br/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'group_name': {
                required: true,
            },

        },
        messages: {
            'account': {
                required: "分组名称不能为空",
            },

        }
    });

    function getOtaName() {
        var ota_name = $('#ota_name').val();
        // ajaxRequest('{:url("api/getparam/")}'+ota_name,'GET','');
        $.get('/api/getparam/'+ota_name,{},function (res) {
            console.log(res)
            $('#config_hezhou').val(res)
        })
    }
</script>
{/block}